package cn.edu.zjut.medlinebackend.service.impl;

import cn.edu.zjut.medlinebackend.mapper.NotificationMapper;
import cn.edu.zjut.medlinebackend.model.Notification;
import cn.edu.zjut.medlinebackend.service.NotificationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class NotificationServiceImpl
        implements NotificationService {

    @Resource
    NotificationMapper notificationMapper;

    @Override
    public List<Notification> getNotificationByUsername(String username) {
        return notificationMapper.selectListByUsername(username);
    }

    @Override
    public boolean markAsRead(Integer notificationid) {
        Notification notification = notificationMapper.selectById(notificationid);
        notificationMapper.updateStatus(notificationid, "已读");
        return true;
    }
}